package user.controller;

import core.controller.BaseController;
import core.domain.Result;
import file.domain.OSSResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import user.service.IFileService;

@RestController
@RequestMapping("/file")
@Slf4j
public class FileController extends BaseController {
    @Autowired
    private IFileService IFileService;

    @PostMapping("/upload")
    public Result<OSSResult> uploadFile(@RequestBody MultipartFile file) {
        log.info("FileController -> uploadFile: {}", file.getOriginalFilename());
        return Result.success(IFileService.uploadFile(file));
    }
}
